package panda.file;


public class Block {
	private String fileName;
	private int blockNumber;
	private int nextBlockNumber = -1;
	
	public static final int BLOCK_SIZE = 4 * 1024;

	public Block(String filename, int blknum) {
		this.fileName = filename;
		this.blockNumber   = blknum;
	}

	public String getFileName() {
		return fileName;
	}

	public int getBlockNumber() {
		return blockNumber;
	}
	
	public int getNextBlockNumber() {
		return nextBlockNumber;
	}
	
	public void setNextBlockNumber(int blknum) {
		nextBlockNumber = blknum;
	}
	
	public Block nextBlock() {
		return new Block(fileName, blockNumber-1);
	}

	public boolean hasNext() {
		return blockNumber>0;
	}
	
	public boolean equals(Object obj) {
		Block blk = (Block) obj;
		return fileName.equals(blk.fileName) && blockNumber == blk.blockNumber;
	}

	public String toString() {
		return "[file " + fileName + ", block " + blockNumber + "]";
	}

	public int hashCode() {
		return toString().hashCode();
	}
}